import Api from '@/services/api.js';
import { mapping } from '@/mixin/mixins/mapping';
import { saveFile } from '@/utils/utils';
export default {
  mixins: [mapping],
  data() {
    return {
      imgUrl: '',
      items: [{
        img: 'https://talentsupload.oss-cn-beijing.aliyuncs.com/miniprogram/common/qrCode.png',
        title: '扫码查看',
        key: 'qrCode'
      }, {
        img: 'https://talentsupload.oss-cn-beijing.aliyuncs.com/miniprogram/common/download.png',
        title: '保存到相册',
        key: 'download'
      }, {
        img: 'https://talentsupload.oss-cn-beijing.aliyuncs.com/miniprogram/common/shareLink.png',
        title: '分享链接',
        key: 'shareLink'
      }]
    }
  },
  computed: {
  },
  onLoad(options) {
   this.imgUrl = options.imgUrl
  },
  methods: {
    handleItem(e) {
      const { item } = e.currentTarget.dataset;
      switch (item.key) {
        case 'qrcode':

          break;
        case 'download':
          this.downloadImg();
          break;
        case 'shareLink':

          break;
      }
    },
    downloadImg() {
      if (!this.imgUrl) {
        return uni.showToast({ title: '图片错误，请重试', icon: 'none' })
      }
      saveFile(this.imgUrl)
    }
  }
}